#include "stringstudialog.h"
#include "ui_stringstudialog.h"
#include "../11-util/01-string_codec_manager/stringcodecmanager.h"
#include "../11-util/02-log_manager/logmanager.h"
#include <QRegularExpression>
StringStuDialog::StringStuDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::StringStuDialog)
{
    ui->setupUi(this);
}

StringStuDialog::~StringStuDialog()
{
    delete ui;
}

void StringStuDialog::on_pushButton_clicked()
{
    QRegularExpression reg("&([^-]*)-");
    QString test = "&11-&22-&33-";
    QString result = StringCodecManager::stringReplace(test,reg,1,[=](QString substring){
        return substring+"dd";
    });
    LogManager::debug("StringStu","click","",QString("result is: %1").arg(result));

}


void StringStuDialog::on_pushButton_2_clicked()
{
    //将所有的/ ==> ,
    QString test = "11/22/33";
     //TODO: 为什么这里要加static
     static QRegularExpression reg("/");

     QString result = test.replace(reg,",");
     LogManager::debug("StringStu","click","",QString("result is: %1").arg(result));
}


void StringStuDialog::on_pushButton_3_clicked()
{
    //将所有的/ ==> ,
    QString test = "&UXZO1mWHTvZZOQ-/QQ&kK5O9ouilgU-";
    QString result = StringCodecManager::imapUtf7Decode(test);

    LogManager::debug("StringStu","click","",QString("result is: %1").arg(result));
}


void StringStuDialog::on_pushButton_4_clicked()
{
    QString test = "其他文件夹";
    QString result = StringCodecManager::imapUtf7Encode(test);
    LogManager::debug("StringStu","click","",QString("result is: %1").arg(result));
}

